package pineapple.p9;

import java.io.File;
import java.io.IOException;
 
/**
 * @author Lenovo
 */
public class RunoobTest {
    public static void main(String[] args) throws IOException {
        File oldName = new File("./runoob-test.txt");
        File newName = new File("./runoob-test-2.txt");
        if (newName.exists()) {
            throw new java.io.IOException("file exists");
        }
        if(oldName.renameTo(newName)) {
            System.out.println("已重命名");
        } else {
            System.out.println("Error");
        }
    }
}